package org.wanghong.gift.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.wanghong.gift.dto.RegisterPhoneValidateDto;
import org.wanghong.gift.service.ISmsValidateCodeService;
import org.wanghong.gift.util.AjaxResult;

import javax.validation.Valid;

@RestController
@RequestMapping("/sms")
public class SmsValidateCodeController {
    @Autowired
    private ISmsValidateCodeService smsValidateCodeService;

    //注册的短信验证码
    @GetMapping("/{phone}")
    public AjaxResult sendRegisterCode(@PathVariable("phone")String phone){
        return smsValidateCodeService.sendRegisterCode(phone);
    }
    @PostMapping("/validate")
    AjaxResult validateRegisterCode(@RequestBody @Valid RegisterPhoneValidateDto dto){
        return smsValidateCodeService.validateRegisterCode(dto);
    }

}
